var AlumniService = RestfulService
		.extend({
			SERVICE_URL : 'api/alumni',
			search : function(query, successcb, errorcb) {
				return this._get(
						this.SERVICE_URL + "/search?keywords=" + query,
						successcb, errorcb);
			},
			advancedSearch : function(conditions, successcb, errorcb) {
				return this._post(this.SERVICE_URL + "/advancedSearch",
						conditions || {}, successcb, errorcb);
			},
			get : function(id, successcb, errorcb) {
				return this._get(this.SERVICE_URL + '/' + id, successcb,
						errorcb);
			},
			remove : function(id, successcb, errorcb) {
				return this._delete(this.SERVICE_URL + '/' + id, successcb,
						errorcb);
			},
			//更新
			updateAlumniInfo : function(postObject, primaryKey, restfulServiceName,
					successcb, errorcb) {
				return this._put(this.SERVICE_URL + '/'
						+ postObject.alumusId
						+ '/' + restfulServiceName + '/'
						+ postObject[primaryKey],
						postObject, successcb, errorcb);
			},
			//创建
			createAlumniInfo : function(postObject, restfulServiceName, successcb,
					errorcb) {
				console.log(this.SERVICE_URL + '/' + postObject.alumusId
								+ '/' + restfulServiceName);	
				console.log(postObject);
				return this._post(
						this.SERVICE_URL + '/' + postObject.alumusId
								+ '/' + restfulServiceName, postObject,
						successcb, errorcb);
			},
			//删除
			removeAlumniInfo : function(alumusId,
					primaryKeyId, restfulServiceName, successcb, errorcb) {
				return this._delete(this.SERVICE_URL + '/' + alumusId
						+ '/' + restfulServiceName + '/' + primaryKeyId,
						successcb, errorcb);
			},
			
			updateAssociation : function(association, successcb, errorcb) {
				return this._put(this.SERVICE_URL + '/'
						+ association.alumusId + '/association', association,
						successcb, errorcb);
			},
			
			updatePersonalInfo : function(personalInfo, successcb, errorcb) {
				return this._put(this.SERVICE_URL + '/'
						+ personalInfo.alumusId + '/personalInfo', personalInfo,
						successcb, errorcb);
			}
		});

(function() {

	var AlumniServiceProvider = Class.extend({

		instance : new AlumniService(),

		/**
		 * Initialize and configure UserModel
		 * 
		 * @return UserModel
		 */
		$get : [ '$http', function($http) {
			this.instance.$http = $http;
			return this.instance;
		} ]
	})

	angular.module('alumni.AlumniService', []).provider('AlumniService',
			AlumniServiceProvider);
}());